<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2016/11/7
  Time: 13:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/mb/jsp/common.jsp" %>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>XX记录</title>
</head>
<body ontouchstart="">
<div class="detailTop pf w100 of">
    <div id="recordTop" class="w100 of tc c3 f18">
        	记录
    </div>
</div>

<div id="container" class="container jz" style="padding-bottom: 0;padding-top: 55px;width:1200px;">

    
    <div id="resText"></div><!--resText-->
        <div id="loading" class="w100">
            <img src="mb/images/loading.gif" alt="正在加载" class="db jz hauto" style="width: 15px;">
            <div class="w100 tc f10 c9">正在加载</div>
        </div>
         <div id="loadingComplete" class="w100" style="display:none;">
            <div class="w100 tc f12 c9">已加载完所有数据</div>
        </div>
    
</div>
 <script>
   //获取url中的参数
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(r[2]); return null; //返回参数值
        }
        
     var recordKind = getUrlParam('recordKind');
	  var m = "";
	  
	  var  backBtn = '<span class="pa" style="left: 5px;" onclick="javascript:history.back();"><img src="mb/images/top_back.png" style="margin-top: 4px;height: 40px;width: 40px;"/></span>';
		if(recordKind == "kangmaidou"){
		  m = 1671;
		  $("#recordTop").html(backBtn+"抗霾豆记录");
		}
		else if(recordKind == "shengwangzhi"){
		  m = 1661;
		  $("#recordTop").html(backBtn+"活跃记录");
		}
		if(recordKind == "zongjine"){
		  m = 1780;
		  $("#recordTop").html(backBtn+"财单记录");
		}
		if(recordKind == "zongedu"){
		  m = 1787;
		  $("#recordTop").html(backBtn+"额度记录");
		}
		
 
 
 
 
	var curpage = 1;
	var total = "";
   //加载新数据
    function getData() {
     console.log("recordKind: " +recordKind);
     console.log("m: " +m);
        $.ajax({
            url: "PlugServlet",
            data: JSON.stringify({m: m,curpage:curpage}),
            type: 'post',
            dataType: 'json',
            contentType: "application/json;charset=utf-8",
            beforeSend: function () {
                showProgressDg();
            },
            success: function (data) {
               if (data.state == 1) {
                
               total = data.total;
                  showData(data.list);
                } else {
                    // 其他错误弹出提示
                    showToast(data.info);
                }
            },
            error: function (data) {
                showToast(data.info);
            },
            complete: function () {
                closeProgressDg();
            }
        });
         return total;
         
    }

 function showData(list)
    {
    	var htmlStr="";
    	var htmlStr2="";
    	
    	$.each(list, function(index, obj) 
    	{
    	    //抗霾+活跃
			var changeValue = obj.logvalue;
			var changeValueBlcok ="";
			
			if(changeValue == 0){
				changeValueBlcok = '<p class="fr f14 c6">'+changeValue+'</p>';
			}
			else if(changeValue > 0){
				changeValueBlcok = '<p class="fr f14 cred">+'+changeValue+'</p>';
			}
			else if(changeValue < 0){
				changeValueBlcok = '<p class="fr f14 cgreen">'+changeValue+'</p>';
			}
    		htmlStr +=
	    		   		'<section class="wdrSection pr w100 bcf hgray">'+
					        '<div class="w100">'+
					            '<div class="w100 of clearfix">'+
					                '<p class="fl f14 c3">'+obj.typeAbout+'</p>'+
					                changeValueBlcok+
					            '</div>'+
					            '<div class="w100 of clearfix">'+
					                '<p class="fl c9 f12">'+dataToString(obj.ctime, "yyyy-MM-dd HH:mm:ss")+'</p>'+
					                '<p class="fr c3 f12">'+obj.newlogvalue+'</p>'+
					            '</div>'+
					        '</div>'+
					    '</section>';
					    
			 //总金额
			var changeValue2 = obj.rmb;
			var changeValueBlcok2 ="";
			
			if(changeValue2 == 0){
				changeValueBlcok2 = '<p class="fr f14 c6">'+changeValue2+'</p>';
			}
			else if(changeValue2 > 0){
				changeValueBlcok2 = '<p class="fr f14 cred">+'+changeValue2+'</p>';
			}
			else if(changeValue2 < 0){
				changeValueBlcok2 = '<p class="fr f14 cgreen">'+changeValue2+'</p>';
			}
					    
			htmlStr2 +=
	    		   		'<section class="wdrSection pr w100 bcf hblue">'+
					        '<div class="w100">'+
					            '<div class="w100 of clearfix">'+
					                '<p class="fl f14 c3">'+obj.typename+'</p>'+
					                changeValueBlcok2 +
					            '</div>'+
					            '<div class="w100 of clearfix">'+
					                '<p class="fl c9 f12">'+obj.timeAbout+'</p>'+
					                '<p class="fr c3 f12">'+obj.nowrmb+'</p>'+
					            '</div>'+
					        '</div>'+
					    '</section>';
    		
    	});
    	
    	 if(recordKind == "kangmaidou"||recordKind == "shengwangzhi"){
    	     $("#resText").after(htmlStr);
    	 }
    	  if(recordKind == "zongjine"||recordKind == "zongedu"){
    	     $("#resText").after(htmlStr2);
    	 }
    	
    }
   
 
	$(document).ready(function(){
	
	getData();
	
			$(window).scroll(function () {
	        if ($(window).scrollTop() == $(document).height() - $(window).height()) {
		           if (curpage < total) {
		               curpage++;
		                $("#loading").slideDown();
		               getData();
		               $("#loading").slideUp();
	              }
	              else {
		               	$("#loadingComplete").slideDown();
		               	var close = function (){
		               	  $("#loadingComplete").slideUp()
		               	};
		   				setTimeout(close,3000);
		   				clearTimeout(close); 
		   				return false;
	              } 
	              
	        }
	 
	    });
	   
	});
</script>


</body>
</html>
